/**
 * Created by Administrator on 2019/9/10.
 */
var unit_price = document.querySelectorAll('.unit-price');
var one = document.querySelectorAll('.one');
var span = document.querySelectorAll('.span');
var price = document.querySelector('.price')
var allSum = 0;
var tr = document.querySelectorAll('.con .right');
//let常量
//var变量
//
function s() {
    for(let i = 0;i< tr.length;i++){
        var two = tr[i].children[0].children[0].innerHTML
        var num = tr[i].children[1].children[0].value
        var count = tr[i].children[2].children[0].innerHTML = (two * num).toFixed(2)
        allSum += Number(count)
    }
    price.innerHTML = allSum.toFixed(2)
}
s()

for(let k = 0;k < one.length;k++){
    one[k].addEventListener('change',s)
}


let del = document.querySelectorAll('.del')

for(let j = 0;j < del.length;j++){
    del[j].addEventListener('click',function () {
        // console.log(this.parentNode.parentNode)
        var con = document.querySelector('.con')
            console.log(con)
            con.removeChild(this.parentNode.parentNode)
        s()
    })
}